const axios = require('axios');

// 监听第一个 API 的数据并发送 POST 请求
function monitorAndSendRequest() {
  setInterval(async () => {
    try {



      const response = await axios.get('https://api.example.com/data');
      const data = response.data.data;

      const testValue = data.find(item => item.identifier === 'test').value;
      const humiValue = data.find(item => item.identifier === 'humi').value;

      if (parseFloat(testValue) > 500 || parseFloat(humiValue) > 50) {
        const postData = {
          // 构建需要发送的数据
        };

        const postResponse = await axios.post('https://api2.example.com/data', postData);
        console.log('POST 请求成功:', postResponse.data);
      }
    }
	catch (error) {
      console.error('Error:', error);
    }
  }, 5000); // 每隔5秒执行一次
}

monitorAndSendRequest();



